package com.dingup.paike.feign.server.classInfo;

import com.alibaba.fastjson.JSONObject;
import com.dingup.api.bean.feign.paike.classInfo.PkClassInfoFeignBean;
import com.dingup.api.model.classInfo.ClassInfo;
import com.dingup.paike.service.pk.PkClassInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by wancheng on 2018/10/29.
 */
@RestController()
@RequestMapping("/paike/feign/classInfo")
public class PaikeClassInfoFeign {

    private static Logger logger = LoggerFactory.getLogger(PaikeClassInfoFeign.class);

    @Autowired
    PkClassInfoService classInfoService;


    @RequestMapping(value = "/add_class_sync_eeo.do", method = RequestMethod.POST)
    public Integer addClassSyncEeo(@RequestBody ClassInfo classInfo) throws Exception {
        logger.info("添加班级班级同步eeo,classInfo={}", JSONObject.toJSONString(classInfo));
        Integer eeoId = null;
        eeoId = classInfoService.addClassAndSyncEEO(classInfo);
        return eeoId;
    }

    @RequestMapping(value = "/update_class_sync_eeo.do", method = RequestMethod.POST)
    public void updateClassSyncEeo(@RequestBody PkClassInfoFeignBean bean) throws Exception {
        logger.info("修改班级同步eeo,oldClass={}", JSONObject.toJSONString(bean.getOldClass()));
        logger.info("修改班级同步eeo,newClass={}", JSONObject.toJSONString(bean.getOldClass()));
        classInfoService.updateClassInfo(bean.getOldClass(), bean.getNewClass());
    }

    @RequestMapping(value = "/delete_class_sync_eeo.do", method = RequestMethod.POST)
    public void deleteClassSyncEeo(Integer classId) throws Exception {
        logger.info("删除班级同步eeo,classId={}", classId);
        classInfoService.deleteClassAndSyncEEO(classId);
    }
}
